package a.e;

import a.j.g;
import a.j.*;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public abstract class k
  extends e
{
  private boolean c;
  private boolean d;
  private double e = 10.0D;
  public static int f;
  
  protected k()
  {
    this(false);
  }
  
  protected k(boolean paramBoolean)
  {
    this.c = paramBoolean;
    this.d = true;
  }
  
  public boolean f()
  {
    return this.d;
  }
  
  public void a(boolean paramBoolean)
  {
    this.d = paramBoolean;
  }
  
  public boolean c()
  {
    return false;
  }
  
  public void a(g paramg, InputStream paramInputStream)
  {
    throw new UnsupportedOperationException("read operation not supported");
  }
  
  public void a(g paramg, OutputStream paramOutputStream)
    throws IOException
  {
    int i = e.b;
    pg localpg1 = (pg)paramg.fb();
    pg localpg2 = localpg1;
    if (i == 0) {
      if (localpg2 == null) {
        localpg2 = a(paramg);
      }
    }
    try
    {
      a(localpg2, paramOutputStream);
      if (i != 0) {}
    }
    finally
    {
      if (localpg1 == null) {
        paramg.c(localpg2);
      }
    }
  }
  
  public void a(pg parampg, OutputStream paramOutputStream)
    throws IOException
  {
    int k = e.b;
    Dimension localDimension = parampg.I();
    long l = localDimension.width * localDimension.height;
    if (l > 2147483647L) {
      throw new IllegalArgumentException("Image size of " + localDimension.width + "x" + localDimension.height + "=" + l + "px exceeds maximum size of " + 2147483647 + "px.");
    }
    BufferedImage localBufferedImage;
    try
    {
      localBufferedImage = a(localDimension.width, localDimension.height);
    }
    catch (OutOfMemoryError localOutOfMemoryError1)
    {
      int i = (int)Math.ceil(localDimension.width * localDimension.height / 1048576.0D);
      throw new OutOfMemoryError("Not enough memory for temporary image of size " + localDimension.width + 'x' + localDimension.height + " (" + i + "MPixels).  Approximately " + i * 4 + "MByte required.");
    }
    Graphics2D localGraphics2D = (Graphics2D)localBufferedImage.getGraphics();
    if (k == 0)
    {
      if (!f()) {
        localGraphics2D.setRenderingHint(kg.a, kg.b);
      }
      if (k != 0) {}
    }
    else if (this.c)
    {
      xe.a(localGraphics2D);
    }
    pc localpc = a(parampg, localGraphics2D);
    if (k == 0)
    {
      if (localpc != null) {
        localGraphics2D.setRenderingHint(kg.z, localpc);
      }
      parampg.a(localGraphics2D);
    }
    if (k == 0) {
      if (this.c) {
        xe.b(localGraphics2D);
      }
    }
    try
    {
      a(localBufferedImage, paramOutputStream);
    }
    catch (OutOfMemoryError localOutOfMemoryError2)
    {
      int j = (int)Math.ceil(localDimension.width * localDimension.height / 1048576.0D);
      throw new OutOfMemoryError("Not enough memory to encode image of size " + localBufferedImage.getWidth() + 'x' + localBufferedImage.getHeight() + " (" + j + "MPixels). Approximately " + j * 4 + "MByte required.");
    }
  }
  
  protected pc a(pg parampg, Graphics2D paramGraphics2D)
  {
    pc localpc = new pc();
    localpc.b(true);
    localpc.a(parampg);
    localpc.a(paramGraphics2D.getTransform());
    return localpc;
  }
  
  protected abstract BufferedImage a(int paramInt1, int paramInt2);
  
  public pg a(g paramg)
  {
    pg localpg = new pg(paramg);
    Rectangle localRectangle = paramg.d();
    Dimension localDimension = new Dimension(localRectangle.width, localRectangle.height);
    localpg.setSize(localDimension);
    localpg.setPreferredSize(localDimension);
    localpg.c(localRectangle.x - this.e, localRectangle.y - this.e, localRectangle.width + 2.0D * this.e, localRectangle.height + 2.0D * this.e);
    localpg.c(0.0D);
    return localpg;
  }
  
  protected abstract void a(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException;
  
  public boolean g()
  {
    return this.c;
  }
  
  public void b(boolean paramBoolean)
  {
    this.c = paramBoolean;
  }
  
  public double h()
  {
    return this.e;
  }
  
  public void a(double paramDouble)
  {
    this.e = paramDouble;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.e.k

 * JD-Core Version:    0.7.0.1

 */